package com.xuan.friend.service.file.impl;

import com.xuan.common.core.exception.BusinessException;
import com.xuan.common.file.domain.OSSResult;
import com.xuan.common.file.service.OSSService;
import com.xuan.friend.service.file.FileService;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;


@Service
public class FileServiceImpl implements FileService {

    @Autowired
    private OSSService ossService;

    @Override
    public OSSResult upload(MultipartFile file) {
        try {
            return ossService.uploadFile(file);
        } catch (IOException e) {
            throw new BusinessException("文件上传失败");
        }
    }
}
